from litemall.api.http import HttpRequests


class SessionApi:
    def __init__(self):
        self.http = HttpRequests()

    def login(self, user, password):
        url = '/wx/auth/login'
        data = {"username": user, "password": password}
        r = self.http.post(url, data=data)
        if r['errmsg'] == '成功':
            return r['data']['token']
        else:
            return []
